package com.songcha.module_home.ui.adapter

import android.content.Context
import android.widget.ImageView
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.songcha.library_business.bean.book.BookNetBean
import com.songcha.library_business.handler.BookStatusHandler
import com.songcha.library_business.interfaces.IOnBookClickListener
import com.songcha.library_business.util.MajiaBaoUtil
import com.songcha.library_common.util.GlideUtil
import com.songcha.library_common.util.StringUtil
import com.songcha.module_home.R

class HomeHomeNewBookShelveAdapter(list:MutableList<BookNetBean>,val listener:IOnBookClickListener):BaseQuickAdapter<BookNetBean,BaseViewHolder> (
    R.layout.home_home_item_newbook_shelve,list){

    init {
        setOnItemClickListener{a,v,p->
            val iv=v.findViewById<ImageView>(R.id.home_item_iv_thumb)
            listener.onBookClick(list[p].bookId.toString(),iv)
        }
    }

    override fun convert(holder: BaseViewHolder, item: BookNetBean) {
        val iv = holder.getView<ImageView>(R.id.home_item_iv_thumb)

        holder.getView<TextView>(R.id.home_item_tv_author).apply {
            text = item.author
        }

        holder.getView<TextView>(R.id.home_item_tv_book_name).apply {
            text = item.bookName
        }

        GlideUtil.loadNetImage(iv,item.cover)

    }

}